package com.ts.log;

import com.ts.comm.SysDate;
import com.ts.jdbc.SysDB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
 * Created by xhc on 2017/3/31.
 */
@Repository
public class LogDaoImpl implements LogDao {

    @Autowired
    private NamedParameterJdbcTemplate jdbcTemplate;
    /**
     * 添加日志
     * @param log
     */
    public void addLog(HashMap<String, Object> log) {
        try {
            String sql="insert into s_log(fRowid,fModelCode,fOpDesc,fUserCode,fIP,fDateTime) ";
            sql+=" values(sys_guid(),:fModelCode,:fOpDesc,:fUserCode,:fIP,:fDateTime)";
            String sDateTime= SysDate.getNowDateTime();
            log.put("fDateTime",sDateTime);
            SysDB.update(jdbcTemplate,sql,log);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
